$('#main_container').ready(function(){
    var top_height=$('#top_container').height();
    var bottom_height=$('#bottom_container').height();
    //主内容区域
    var maincontent_height = client_height-top_height-bottom_height;
    //主内容区域的高宽
    var maincontent_ratio = maincontent_height/$('#container').width();
    var banner1_width = $('#container').width();
    var banner1_height = maincontent_height;
    $('#banner1_container').css('height',maincontent_height);
    $('#banner1_container .swiper-slide img').css('height',maincontent_height+"px");
    $('#banner1_container .swiper-slide img').css('width',banner1_width+"px");
    //获取图片相对于屏幕主内容的偏移量
    var banner1_offset = parseInt((maincontent_height-banner1_height)/2)+top_height;
    //alert(top_height);
    $('#banner1_container').css('margin-top',(top_height)+"px");


    //渐现第一张图片
    var img1_ori_src= $('.swiper-slide img:eq(0)').attr('data-original');
    $('.swiper-slide img:eq(0)').attr('src',img1_ori_src);
    $('.swiper-slide img:eq(0)').removeAttr('data-original');
    $('.swiper-slide img:eq(0)').fadeIn(500);


    adapt_albumCover();


    $(window).resize(function(){
        //获取图片相对于屏幕主内容的偏移量
        var banner1_offset = parseInt(($('#container').width()-banner1_width)/2);
        //alert(top_height);
        $('#banner1_container').css('margin-left',banner1_offset+"px");
        $('#banner1_container').css('width',banner1_width+"px");
        /*if(mySwiper){
            mySwiper.onResize();
        }*/
    });

});



$(window).resize(function(){
    window_width = $(window).width();
    client_height =document.documentElement.clientHeight;
    //client_width = document.documentElement.clientWidth;
    client_width = $('#container').width();
    window_height = window_width*client_height/$('#container').width();
    adapt_albumCover();

});

function adapt_albumCover(){
    //获取画册封面原大小
    var $albumCover = $('#albumCover');
    var albumCover_height =$albumCover.attr('data-oriheight');
    var albumCover_width =$albumCover.attr('data-oriwidth');
    var albumCover_ratio = albumCover_height/albumCover_width;
    var adapt_type = "";
    //获取屏幕顶、底栏的高度（放在全局无法获取，放在$.ready此函数无法调用）
    var top_height=$('#top_container').height();
    var bottom_height=$('#bottom_container').height();
    //主内容区域
    var maincontent_height = client_height-top_height-bottom_height;
    //主内容区域的高宽
    var maincontent_ratio = maincontent_height/$('#container').width();
    if(is_iphone>0 || is_ipad>0 || is_android>0){
        //如果是非PC端
        if((maincontent_ratio)>1 && maincontent_ratio>albumCover_ratio ){
            //主内容为竖屏且主内容区域比例大于图片比例
            var adapt_albumCover_width = $('#container').width()*0.8;
            var adapt_albumCover_height = parseInt(adapt_albumCover_width*albumCover_ratio);
            $albumCover.css('width',adapt_albumCover_width+"px");
            $albumCover.css('height',adapt_albumCover_height+"px");
        }else{
            //将图片按横屏处理
            var adapt_albumCover_height = maincontent_height*0.7;
            var adapt_albumCover_width = parseInt(adapt_albumCover_height/albumCover_ratio);
            $albumCover.css('width',adapt_albumCover_width+"px");
            $albumCover.css('height',adapt_albumCover_height+"px");
        }
    }else{
        //如果是PC。
        if(albumCover_ratio>1){
            //如果图片是竖图
            var adapt_albumCover_height = maincontent_height*0.7;
            var adapt_albumCover_width = parseInt(adapt_albumCover_height/albumCover_ratio);
            $albumCover.css('width',adapt_albumCover_width+"px");
            $albumCover.css('height',adapt_albumCover_height+"px");
        }else{
            var adapt_albumCover_width = $('#container').width()*0.8;
            var adapt_albumCover_height = parseInt(adapt_albumCover_width*albumCover_ratio);
            $albumCover.css('width',adapt_albumCover_width+"px");
            $albumCover.css('height',adapt_albumCover_height+"px");
        }

    }


    //获取图片相对于屏幕主内容的偏移量
    var albumCover_offset = parseInt((maincontent_height-adapt_albumCover_height)/2)+top_height;
    //alert(top_height);

    $albumCover.css('margin-top',albumCover_offset+"px");
    $('#albumCover').css('visibility','visible');
}